﻿<Page
    x:Class="Cookbook.Views.RecipesView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Cookbook.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:core="using:Microsoft.Xaml.Interactions.Core"
    xmlns:vm="using:Cookbook.ViewModels"
    mc:Ignorable="d"
    d:DataContext="{d:DesignInstance Type=vm:RecipesViewModel}">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <Grid.RowDefinitions>
            <RowDefinition Height="140" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TextBlock Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" 
                   IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" 
                   Margin="120,0,30,40"/>
        
        <GridView ItemsSource="{Binding Recipes}" Grid.Row="1" Margin="120,0,0,0">
            <GridView.ItemTemplate>
                <DataTemplate>
                    <Image Source="{Binding ImagePath}" Width="300" Height="300" Stretch="UniformToFill">
                        <interactivity:Interaction.Behaviors>
                            <core:EventTriggerBehavior EventName="Tapped">
                                <core:NavigateToPageAction TargetPage="Cookbook.Views.RecipeDetailView"
                                                           Parameter="{Binding Id}" />
                            </core:EventTriggerBehavior>
                        </interactivity:Interaction.Behaviors>
                    </Image>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>
        
    </Grid>
</Page>
